#ifndef EVOLUTIONENGINE_H
#define EVOLUTIONENGINE_H

#include "Candidate.h"
#include "Tournament.h"
#include "FitnessEvaluator.h"
#include "CandidateFactory.h"

class EvolutionEngine
{
public:
    EvolutionEngine(int populationSize,int geneSize,Tournament *tour, FitnessEvaluator *fe,int epochSize, std::vector<Candidate*>  candidates);
    ~EvolutionEngine();
    Candidate* migrateCandidate();
    void introduceImmigrant(Candidate* candidate);
    bool evolve();
    float getFinalValue();
    //CandidateFactory* cf;
    void setTargetValue(float targetValue);
    Candidate* getWinner();
private:
    int epochSize;
    int epochCount;
    int finalValI;
    int populationSize;
    int geneSize;
    bool finished;
    void finalizeEvolve();
    void bulkEvolve();
    std::vector<Candidate*>  candidates;
    std::vector<Candidate*>  result;
    Tournament *tour;
    FitnessEvaluator *fe;
};

#endif // EVOLUTIONENGINE_H
